<?php

// +----------------------------------------------------------------------
// | H1CMS © OpenSource CMS
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2016 http://www.h1cms.com All rights reserved.
// | Copyright (c) 2014-2016 嘉兴领格信息技术有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Allen <allen@lg4.cn>
// +----------------------------------------------------------------------

use Lg\Http\Input;
use h1cms\H1;

function maintenance($status = 0) {
    if ($status) {
        H1::$app->db->update('options', ['option_value' => 1], ['option_group' => 'site', 'option_name' => 'maintenance']);
        file_put_contents(STORAGE_DIR . '.maintenance', Input::post('maintenance_info', '系统维护中,请稍后访问 ...'));
    } else {
        H1::$app->db->update('options', ['option_value' => 0], ['option_group' => 'site', 'option_name' => 'maintenance']);
        @unlink(STORAGE_DIR . '.maintenance');
    }
}
